import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../auth/login/widget/verification_code_timer_widget.dart';

class CancelAccountPage extends StatefulWidget {
  const CancelAccountPage({super.key});

  @override
  State<CancelAccountPage> createState() => _CancelAccountPageState();
}

class _CancelAccountPageState extends State<CancelAccountPage> {
  String code = '';
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: BrnAppBar(title: '注销账号'),
      backgroundColor: Colors.white,
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 20),
        child: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text('注销账号请验证以下手机号：',
                  style: TextStyle(color: const Color(0xFF000000), fontSize: 17.sp, fontWeight: FontWeight.w600)),
              const SizedBox(height: 30),
              Row(
                children: [
                  Text('手机号',
                      style: TextStyle(color: const Color(0xFF000000), fontSize: 15.sp, fontWeight: FontWeight.w500)),
                  const SizedBox(width: 15),
                  Text('130****5105', style: TextStyle(color: const Color(0xFF000000), fontSize: 15.sp)),
                  const Divider(color: Color(0xFFEEEEEE), height: 0.5, indent: 15, endIndent: 15)
                ],
              ),
              const SizedBox(height: 30),
              Row(
                children: [
                  Text('验证码',
                      style: TextStyle(color: const Color(0xFF000000), fontSize: 15.sp, fontWeight: FontWeight.w500)),
                  const SizedBox(width: 15),
                  Expanded(
                    child: SizedBox(
                      child: TextField(
                        maxLength: 4,
                        obscureText: false,
                        cursorWidth: 2,
                        cursorColor: const Color(0xFF2CC0B1),
                        autofocus: false,
                        onChanged: (value) {
                          code = value;
                          setState(() {});
                        },
                        onSubmitted: (value) {
                          code = value;
                          setState(() {});
                        },
                        keyboardType: TextInputType.phone,
                        inputFormatters: [
                          FilteringTextInputFormatter.allow(RegExp(r'[0-9]')) //设置只允许输入数字
                        ],
                        style: TextStyle(color: const Color(0xFF000000), fontSize: 14.sp),
                        decoration: InputDecoration(
                            hintText: '请输入验证码',
                            counterText: '',
                            hintStyle: TextStyle(color: const Color(0xFF999999), fontSize: 15.sp),
                            border: InputBorder.none),
                      ),
                    ),
                  ),
                  VercodeTimerWidget(
                    verifyBuilder: () {
                      // if (!logic.isChecked) {
                      //   Toast.showText('请先阅读并同意协议');
                      //   return false;
                      // }
                      // if (state.phone.length != 11 ||
                      //     state.phone.startsWith('10') ||
                      //     state.phone.startsWith('11') ||
                      //     state.phone.startsWith('12')) {
                      //   Toast.showText('请输入正确的手机号');
                      //   return false;
                      // }
                      return true;
                    },
                    builder: () async {
                      /// 调取成功接口开始倒计时
                      return true;
                      // await logic.requestSendVerifyCode();
                    },
                  )
                ],
              ),
              Padding(
                padding: const EdgeInsets.only(top: 50),
                child: BrnBigMainButton(
                  title: "确认".tr,
                  width: double.infinity - 32 * 2,
                  bgColor: const Color(0xFF25D4D0),
                  bgDisEnableColor: const Color(0xFF25D4D0).withOpacity(0.6),
                  themeData: BrnButtonConfig(bigButtonRadius: 255, bigButtonHeight: 45.h, bigButtonFontSize: 16.sp),
                  isEnable: code.length == 4,
                  onTap: () {},
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
